require('es6-promise').polyfill();

import axios from 'axios'

function loadSysRolePermissionData(data){
  return {
    type: 'LOAD_SYSROLE_PERMISSION_DATA',
    data
  }
}

export function loadSysRolePermissionDataAsync() {
  // console.log('queryPermission')
  return function(dispatch) {
    return axios.post('/api/sysrolePermission/queryPermission').then(
      resp => dispatch(loadSysRolePermissionData(resp.data)),
      error => dispatch(loadSysRolePermissionData([]))
    );
  };
}

export function deleteSysRolePermissionDataAsync(data) {
  // console.log('queryPermission')
  return function(dispatch) {
    return axios.post('/api/sysrole/deleteRoles',data).then(
      resp => dispatch(loadSysRolePermissionDataAsync()),
      error => dispatch(loadSysRolePermissionDataAsync())
    );
  };
}
